<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>git 相关总结 | 人间熙攘，好久不见</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="/favicon.ico">
    <script charset="utf-8" crossorigin="anonymous" src="/js/rainyday.js"></script>
    <meta name="description" content="人间熙攘，好久不见~ Magic 的博客">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    <meta name="google-site-verification" content="cFm07VssWCh93-dPrep06FyYb3ST7MIfQnx9B6ZcYsQ">
    
    <link rel="preload" href="/assets/css/0.styles.fe1de732.css" as="style"><link rel="preload" href="/assets/js/app.fe0f04fe.js" as="script"><link rel="preload" href="/assets/js/3.8f0a3ee6.js" as="script"><link rel="preload" href="/assets/js/1.0d4da6ad.js" as="script"><link rel="preload" href="/assets/js/7.ccf4b6c6.js" as="script"><link rel="prefetch" href="/assets/js/10.c5719ae1.js"><link rel="prefetch" href="/assets/js/11.22795e1d.js"><link rel="prefetch" href="/assets/js/12.35a1eee1.js"><link rel="prefetch" href="/assets/js/13.ef37c62d.js"><link rel="prefetch" href="/assets/js/14.f36a185b.js"><link rel="prefetch" href="/assets/js/15.06ade84c.js"><link rel="prefetch" href="/assets/js/16.3d06e6fb.js"><link rel="prefetch" href="/assets/js/17.7dd5742a.js"><link rel="prefetch" href="/assets/js/18.7bff1c11.js"><link rel="prefetch" href="/assets/js/19.7bb3239d.js"><link rel="prefetch" href="/assets/js/20.501cb431.js"><link rel="prefetch" href="/assets/js/21.8cfea759.js"><link rel="prefetch" href="/assets/js/22.ef6af803.js"><link rel="prefetch" href="/assets/js/23.8b263173.js"><link rel="prefetch" href="/assets/js/24.dd9f70b8.js"><link rel="prefetch" href="/assets/js/25.4ec78de4.js"><link rel="prefetch" href="/assets/js/26.8e7888cc.js"><link rel="prefetch" href="/assets/js/27.a78de168.js"><link rel="prefetch" href="/assets/js/28.9faf1a01.js"><link rel="prefetch" href="/assets/js/4.a1817f8d.js"><link rel="prefetch" href="/assets/js/5.779f467f.js"><link rel="prefetch" href="/assets/js/6.6a2cdf6b.js"><link rel="prefetch" href="/assets/js/8.27e71aa7.js"><link rel="prefetch" href="/assets/js/9.6dcd52b0.js">
    <link rel="stylesheet" href="/assets/css/0.styles.fe1de732.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container" data-v-2d5f533b><div data-v-2d5f533b><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-2d5f533b data-v-2d5f533b><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-64685f0e data-v-2d5f533b data-v-2d5f533b><h3 class="title" style="display:none;" data-v-64685f0e data-v-64685f0e>人间熙攘，好久不见</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-64685f0e data-v-64685f0e><input type="password" value="" data-v-64685f0e> <span data-v-64685f0e>Konck! Knock!</span> <button data-v-64685f0e>OK</button></label> <div class="footer" style="display:none;" data-v-64685f0e data-v-64685f0e><span data-v-64685f0e><i class="iconfont reco-theme" data-v-64685f0e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-64685f0e>vuePress-theme-reco</a></span> <span data-v-64685f0e><i class="iconfont reco-copyright" data-v-64685f0e></i> <a data-v-64685f0e><span data-v-64685f0e>Magic</span>
            
          <span data-v-64685f0e>2017 - </span>
          2022
        </a></span></div></div> <div class="hide" data-v-2d5f533b><header class="navbar" data-v-2d5f533b><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/logo/nav.png" alt="人间熙攘，好久不见" class="logo"> <span class="site-name">人间熙攘，好久不见</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      Category
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/tools/" class="nav-link"><i class="iconfont undefined"></i>
  tools
</a></li><li class="dropdown-item"><!----> <a href="/categories/Zsh/" class="nav-link"><i class="iconfont undefined"></i>
  Zsh
</a></li><li class="dropdown-item"><!----> <a href="/categories/iTerm2/" class="nav-link"><i class="iconfont undefined"></i>
  iTerm2
</a></li><li class="dropdown-item"><!----> <a href="/categories/Front-end/" class="nav-link"><i class="iconfont undefined"></i>
  Front-end
</a></li><li class="dropdown-item"><!----> <a href="/categories/版本控制-Git/" class="nav-link"><i class="iconfont undefined"></i>
  版本控制-Git
</a></li><li class="dropdown-item"><!----> <a href="/categories/Rust/" class="nav-link"><i class="iconfont undefined"></i>
  Rust
</a></li><li class="dropdown-item"><!----> <a href="/categories/skia-safe/" class="nav-link"><i class="iconfont undefined"></i>
  skia-safe
</a></li><li class="dropdown-item"><!----> <a href="/categories/第三方对接/" class="nav-link"><i class="iconfont undefined"></i>
  第三方对接
</a></li><li class="dropdown-item"><!----> <a href="/categories/Powershell/" class="nav-link"><i class="iconfont undefined"></i>
  Powershell
</a></li><li class="dropdown-item"><!----> <a href="/categories/python/" class="nav-link"><i class="iconfont undefined"></i>
  python
</a></li><li class="dropdown-item"><!----> <a href="/categories/wsl2/" class="nav-link"><i class="iconfont undefined"></i>
  wsl2
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tags
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  TimeLine
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont undefined"></i>
      GitHub
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://github.com/magicLaLa/Magic.me" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  Github
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://github.com/magicLaLa/blog" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  Before
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-2d5f533b></div> <aside class="sidebar" data-v-2d5f533b><div class="personal-info-wrapper" data-v-ca798c94 data-v-2d5f533b><img src="/logo/avatar2.gif" alt="author-avatar" class="personal-img" data-v-ca798c94> <h3 class="name" data-v-ca798c94>
    Magic
  </h3> <div class="num" data-v-ca798c94><div data-v-ca798c94><h3 data-v-ca798c94>18</h3> <h6 data-v-ca798c94>文章</h6></div> <div data-v-ca798c94><h3 data-v-ca798c94>11</h3> <h6 data-v-ca798c94>标签</h6></div></div> <hr data-v-ca798c94></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      Category
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/tools/" class="nav-link"><i class="iconfont undefined"></i>
  tools
</a></li><li class="dropdown-item"><!----> <a href="/categories/Zsh/" class="nav-link"><i class="iconfont undefined"></i>
  Zsh
</a></li><li class="dropdown-item"><!----> <a href="/categories/iTerm2/" class="nav-link"><i class="iconfont undefined"></i>
  iTerm2
</a></li><li class="dropdown-item"><!----> <a href="/categories/Front-end/" class="nav-link"><i class="iconfont undefined"></i>
  Front-end
</a></li><li class="dropdown-item"><!----> <a href="/categories/版本控制-Git/" class="nav-link"><i class="iconfont undefined"></i>
  版本控制-Git
</a></li><li class="dropdown-item"><!----> <a href="/categories/Rust/" class="nav-link"><i class="iconfont undefined"></i>
  Rust
</a></li><li class="dropdown-item"><!----> <a href="/categories/skia-safe/" class="nav-link"><i class="iconfont undefined"></i>
  skia-safe
</a></li><li class="dropdown-item"><!----> <a href="/categories/第三方对接/" class="nav-link"><i class="iconfont undefined"></i>
  第三方对接
</a></li><li class="dropdown-item"><!----> <a href="/categories/Powershell/" class="nav-link"><i class="iconfont undefined"></i>
  Powershell
</a></li><li class="dropdown-item"><!----> <a href="/categories/python/" class="nav-link"><i class="iconfont undefined"></i>
  python
</a></li><li class="dropdown-item"><!----> <a href="/categories/wsl2/" class="nav-link"><i class="iconfont undefined"></i>
  wsl2
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tags
</a></div><div class="nav-item"><a href="/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  TimeLine
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont undefined"></i>
      GitHub
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://github.com/magicLaLa/Magic.me" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  Github
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://github.com/magicLaLa/blog" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont undefined"></i>
  Before
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group collapsable depth-0"><p class="sidebar-heading open"><span>Git</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/Contents/Git/GitBranch.html" class="sidebar-link">git 一些骚操作</a></li><li><a href="/Contents/Git/GitCommitEmoji.html" class="sidebar-link">git commit emoji 使用指南</a></li><li><a href="/Contents/Git/GitProxy.html" class="sidebar-link">git 设置代理</a></li><li><a href="/Contents/Git/GitSummary.html" aria-current="page" class="active sidebar-link">git 相关总结</a></li></ul></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-64685f0e data-v-2d5f533b><h3 class="title" style="display:none;" data-v-64685f0e data-v-64685f0e>git 相关总结</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-64685f0e data-v-64685f0e><input type="password" value="" data-v-64685f0e> <span data-v-64685f0e>Konck! Knock!</span> <button data-v-64685f0e>OK</button></label> <div class="footer" style="display:none;" data-v-64685f0e data-v-64685f0e><span data-v-64685f0e><i class="iconfont reco-theme" data-v-64685f0e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-64685f0e>vuePress-theme-reco</a></span> <span data-v-64685f0e><i class="iconfont reco-copyright" data-v-64685f0e></i> <a data-v-64685f0e><span data-v-64685f0e>Magic</span>
            
          <span data-v-64685f0e>2017 - </span>
          2022
        </a></span></div></div> <div data-v-2d5f533b><main class="page"><div class="page-title" style="display:none;"><h1 class="title">git 相关总结</h1> <div data-v-3b7f5bdf><i class="iconfont reco-account" data-v-3b7f5bdf><span data-v-3b7f5bdf>Magic</span></i> <i class="iconfont reco-date" data-v-3b7f5bdf><span data-v-3b7f5bdf>2017-06-02</span></i> <i class="iconfont reco-eye" data-v-3b7f5bdf><span id="/Contents/Git/GitSummary.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-3b7f5bdf><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="iconfont reco-tag tags" data-v-3b7f5bdf><span class="tag-item" data-v-3b7f5bdf>Git</span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><h1 id="关于git的总结"><a href="#关于git的总结" class="header-anchor">#</a> 关于git的总结</h1> <h2 id="git工作流"><a href="#git工作流" class="header-anchor">#</a> git工作流</h2> <p><img src="/assets/img/git-flow.48567a91.png" alt="pic"></p> <h2 id="git相关"><a href="#git相关" class="header-anchor">#</a> git相关</h2> <ul><li><p><a href="https://www.conventionalcommits.org/zh/v1.0.0-beta.2/" target="_blank" rel="noopener noreferrer">git 提交规范<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="http://rogerdudler.github.io/git-guide/index.zh.html" target="_blank" rel="noopener noreferrer">git 简明指南<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="https://learngitbranching.js.org/" target="_blank" rel="noopener noreferrer">git 在线教程<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="https://git-scm.com/book/zh/v2" target="_blank" rel="noopener noreferrer">git pro 中文教程<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><p><a href="https://github.com/commitizen/cz-cli" target="_blank" rel="noopener noreferrer">Commitizen<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>是一个撰写合格 Commit message 的工具。</p></li></ul> <p>1.安装命令如下:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">npm</span> <span class="token function">install</span> -g commitizen
</code></pre></div><p>2.然后，在项目目录里，运行下面的命令，使其支持 Angular 的 Commit message 格式</p> <div class="language-bash extra-class"><pre class="language-bash"><code>commitizen init cz-conventional-changelog --save --save-exact
</code></pre></div><p>3.以后，凡是用到git commit命令，一律改为使用git cz。这时，就会出现选项，用来生成符合格式的 Commit message</p> <p><img src="/assets/img/add-commit.b2176482.png" alt="Alt text"></p> <ul><li>更多关于<code>Commit message 和 Change log 编写指南</code>可以到<a href="http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html" target="_blank" rel="noopener noreferrer">Commit message 和 Change log 编写指南<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>查看...</li></ul> <h2 id="git操作"><a href="#git操作" class="header-anchor">#</a> git操作</h2> <h3 id="合并某个分支上的文件到应一个分支、回退到某个版本和-远程服务器上面回退到某个版本"><a href="#合并某个分支上的文件到应一个分支、回退到某个版本和-远程服务器上面回退到某个版本" class="header-anchor">#</a> 合并某个分支上的文件到应一个分支、回退到某个版本和 远程服务器上面回退到某个版本</h3> <ol><li>git 合并某个分支上的文件到另一个分支上<code>git checkout branch &lt;path&gt;</code></li> <li>git 本地回退到某个版本</li></ol> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">git</span> reset --hard 23bc94cf7e3c74c33dd4575dfbf72d6647333795
</code></pre></div><ol start="3"><li>git 远程服务器上面回退到某个版本</li></ol> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token comment"># 可以 先把本地回退到某个版本</span>
<span class="token comment"># 例如：</span>
<span class="token function">git</span> reset --hard 23bc94cf7e3c74c33dd4575dfbf72d6647333795
<span class="token comment"># 然后再 强推到远程上面</span>
<span class="token function">git</span> push -f
</code></pre></div><h3 id="删除远程仓库上的某个文件夹"><a href="#删除远程仓库上的某个文件夹" class="header-anchor">#</a> 删除远程仓库上的某个文件夹</h3> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token comment"># 查看有哪些文件夹</span>
$ <span class="token function">dir</span>
<span class="token comment"># 删除某个文件夹（本地项目中的文件夹不受操作影响,删除的只是远程仓库中的文件夹）</span>
$ <span class="token function">git</span> <span class="token function">rm</span> -r --cached target
<span class="token comment"># 提交,添加操作说明</span>
$ <span class="token function">git</span> commit -m <span class="token string">'删除了xxx文件夹'</span>

<span class="token comment"># 列子</span>
<span class="token function">git</span> <span class="token function">rm</span> -r --cached .idea  <span class="token comment">#--cached不会把本地的.idea删除</span>
<span class="token function">git</span> commit -m <span class="token string">'delete .idea dir'</span>
<span class="token function">git</span> push -u origin master
</code></pre></div><h3 id="git-tag"><a href="#git-tag" class="header-anchor">#</a> Git Tag</h3> <ul><li><code>git tag</code>查看所有的标签</li> <li><code>git tag -d tagName</code> 删除某个标签</li> <li><code>git tag -a newName -m &quot;注释&quot;</code> 创建一个带注释的标签</li> <li><code>git tag newName</code> 创建一个轻量级标签</li> <li><code>git checkout tagName</code> 切换到某个标签</li> <li>可以按照特定的表达式搜索某些标签</li></ul> <div class="language-sh extra-class"><pre class="language-sh"><code>$ <span class="token function">git</span> tag -l v1.2.*
  v1.2.1
  v1.2.2
  v1.2.3
</code></pre></div><ul><li><code>git push --tags</code> 默认情况下，<code>git push</code> 不会把 tag 上传到远程，为了共享这个 tag，可以在 git push 后面加 <code>--tags</code></li> <li><code>git stash</code> 暂存区和工作区的状态都会被保存</li> <li><code>git show tagName</code> 查看该标签的信息</li> <li>注意 <em><code>tag</code>实际指向的是一次<code>commit</code>，<code>show tagName</code>展示出来的<code>diff</code>也是该次<code>commit</code>的<code>diff</code></em></li> <li>删除本地标签 <code>git tag -d 标签名</code></li> <li>删除远程标签 <code>git push origin :refs/tags/标签名</code></li></ul> <h3 id="git-推送本地分支到远程和拉去远程分支到本地"><a href="#git-推送本地分支到远程和拉去远程分支到本地" class="header-anchor">#</a> git 推送本地分支到远程和拉去远程分支到本地</h3> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">git</span> push <span class="token operator">&lt;</span>远程主机名<span class="token operator">&gt;</span> <span class="token operator">&lt;</span>本地分支名<span class="token operator">&gt;</span>:<span class="token operator">&lt;</span>远程分支名<span class="token operator">&gt;</span>
<span class="token function">git</span> fetch origin <span class="token operator">&lt;</span>远程分支名<span class="token operator">&gt;</span>:<span class="token operator">&lt;</span>本地分支名<span class="token operator">&gt;</span>
</code></pre></div><h3 id="git-回到远程仓库的状态"><a href="#git-回到远程仓库的状态" class="header-anchor">#</a> git 回到远程仓库的状态</h3> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">git</span> fetch --all <span class="token operator">&amp;&amp;</span> <span class="token function">git</span> reset --hard origin/master
</code></pre></div><h3 id="git-放弃工作区的修改"><a href="#git-放弃工作区的修改" class="header-anchor">#</a> git 放弃工作区的修改</h3> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">git</span> checkout <span class="token operator">&lt;</span>file-name<span class="token operator">&gt;</span>
<span class="token comment"># 放弃所有更改:</span>
<span class="token function">git</span> checkout <span class="token builtin class-name">.</span>
</code></pre></div><h3 id="以新增一个commit的方式还原某一个commit的修改"><a href="#以新增一个commit的方式还原某一个commit的修改" class="header-anchor">#</a> 以新增一个commit的方式还原某一个commit的修改</h3> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">git</span> revert <span class="token operator">&lt;</span>commit-id<span class="token operator">&gt;</span>
</code></pre></div><h3 id="回到某个commit的状态-并删除后面的commit"><a href="#回到某个commit的状态-并删除后面的commit" class="header-anchor">#</a> 回到某个commit的状态，并删除后面的commit</h3> <p>和revert的区别：reset命令会抹去某个commit id之后的所有commit</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">git</span> reset <span class="token operator">&lt;</span>commit-id<span class="token operator">&gt;</span>  <span class="token comment">#默认就是-mixed参数。</span>

<span class="token function">git</span> reset –mixed HEAD^  <span class="token comment">#回退至上个版本，它将重置HEAD到另外一个commit,并且重置暂存区和HEAD相匹配，但是也到此为止。工作区不会被更改。</span>

<span class="token function">git</span> reset –soft HEAD~3  <span class="token comment">#回退至三个版本之前，只回退了commit的信息，暂存区和工作区与回前保持一致。如果还要提交，直接commit即可</span>

<span class="token function">git</span> reset –hard <span class="token operator">&lt;</span>commit-id<span class="token operator">&gt;</span>  <span class="token comment">#彻底回退到指定commit-id的状态，暂存区和工作区也会变为commit-id版本的内容</span>
</code></pre></div><h3 id="以上是常用的几种-更多"><a href="#以上是常用的几种-更多" class="header-anchor">#</a> 以上是常用的几种，更多：</h3> <ul><li><a href="https://github.com/magicLaLa/git-tips" target="_blank" rel="noopener noreferrer">关于git的操作请访问Fork=&gt;https://github.com/521xueweihan<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <h2 id="git设置、powershell-插件-posh-git-安装、可视化界面的项目版本控制软件-适用于git项目管理"><a href="#git设置、powershell-插件-posh-git-安装、可视化界面的项目版本控制软件-适用于git项目管理" class="header-anchor">#</a> git设置、PowerShell 插件 posh-git 安装、可视化界面的项目版本控制软件，适用于git项目管理</h2> <ul><li>Git 设置</li></ul> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token comment"># 设置 Git 全局：用户名、邮箱 ↓</span>
<span class="token function">git</span> config --global user.name <span class="token string">&quot;youName&quot;</span>
<span class="token function">git</span> config --global user.email yourEmail@example.com

<span class="token comment"># 下面是针对每个 Git 项目的，非全局 ↓</span>
<span class="token function">git</span> config user.email yourEmail@example.com
<span class="token function">git</span> config user.name <span class="token string">&quot;youName&quot;</span>

<span class="token comment"># 禁用git自动LF转CRLF</span>
<span class="token function">git</span> config --global core.autocrlf <span class="token boolean">false</span>
<span class="token comment"># 生成密钥（默认文件名id_rsa）</span>
<span class="token comment"># -t 密钥类型</span>
<span class="token comment"># -C 注释</span>
ssh-keygen -t rsa -C <span class="token string">&quot;邮箱&quot;</span>
</code></pre></div><p>哪个设为全局，哪个设为当前项目，按个人需求而定，并无绝对。</p> <ul><li>PowerShell 插件 posh-git 安装</li></ul> <div class="language-sh extra-class"><pre class="language-sh"><code>VSCode 默认使用PowerShell，启动powershell，分别执行下面3个命令（提示都输入Yes）
<span class="token comment"># 1.设置权限</span>
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
<span class="token comment"># 2.使用PowerShellGet安装</span>
PowerShellGet<span class="token punctuation">\</span>Install-Module posh-git -Scope CurrentUser
<span class="token comment"># 3.全局导入posh-git</span>
Add-PoshGitToProfile -AllHosts
</code></pre></div><ul><li><p>SourceTree拥有可视化界面的项目版本控制软件，适用于git项目管理
<a href="https://www.sourcetreeapp.com/" target="_blank" rel="noopener noreferrer">官网<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>
基本使用: <a href="https://www.cnblogs.com/tian-xie/p/6264104.html" target="_blank" rel="noopener noreferrer">https://www.cnblogs.com/tian-xie/p/6264104.html<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <p><img src="/assets/img/sourcetree.d791c81f.png" alt="SourceTree"></p></li></ul> <h2 id="git常见错误处理"><a href="#git常见错误处理" class="header-anchor">#</a> git常见错误处理</h2> <h3 id="在-git-commit-或者-git-add-的时候报-git-fatal-unable-to-create-f-vue-learning-git-index-lock-file-exists-这个错误"><a href="#在-git-commit-或者-git-add-的时候报-git-fatal-unable-to-create-f-vue-learning-git-index-lock-file-exists-这个错误" class="header-anchor">#</a> 在 git commit 或者 git add 的时候报 Git: fatal: Unable to create 'f:/Vue-learning/.git/index.lock': File exists. 这个错误</h3> <ul><li>git 遇到这个错误时，需要把 当前项目下 .git -&gt; index.lock 这个文件删除即可</li></ul> <p><img src="/assets/img/1323758-20180206172305857-1172749425.a9329d6e.png" alt="Alt text"></p> <h3 id="git-merge-冲突-提示you-have-not-concluded-your-merge-merge-head-exists"><a href="#git-merge-冲突-提示you-have-not-concluded-your-merge-merge-head-exists" class="header-anchor">#</a> git merge 冲突，提示You have not concluded your merge (MERGE_HEAD exists)</h3> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token comment"># You have not concluded your merge (MERGE_HEAD exists).</span>
<span class="token comment"># Please, commit your changes before you can merge.</span>
<span class="token comment"># 可以先撤销合并(git的版本不同撤销命令也不同)</span>
<span class="token function">git</span> merge --abort <span class="token punctuation">[</span>Since <span class="token function">git</span> version <span class="token number">1.7</span>.4<span class="token punctuation">]</span>
<span class="token function">git</span> reset --merge <span class="token punctuation">[</span>prior <span class="token function">git</span> versions<span class="token punctuation">]</span>
</code></pre></div><h3 id="git-clone-远程仓库地址url-在登录时输错密码或者账户导致clong失败"><a href="#git-clone-远程仓库地址url-在登录时输错密码或者账户导致clong失败" class="header-anchor">#</a> git clone 远程仓库地址url，在登录时输错密码或者账户导致clong失败</h3> <ol><li>打开电脑控制面板：</li></ol> <p><img src="/assets/img/kzmb.9522e40f.png" alt="控制面板"></p> <ol start="2"><li>选择用户账户--&gt;管理你的凭据</li></ol> <p><img src="/assets/img/dnpz.bd29ef69.png" alt="电脑凭证"></p> <ol start="3"><li>可以在下方用红框的地方修改</li></ol> <p><img src="/assets/img/pz.c7a6b0da.png" alt="修改"> <img src="/assets/img/xg.b4b356d7.png" alt="修改"></p> <h3 id="git-push-到-github-上报错-fatal-httprequestexception-encountered"><a href="#git-push-到-github-上报错-fatal-httprequestexception-encountered" class="header-anchor">#</a> git push 到 github 上报错：fatal: HttpRequestException encountered</h3> <div class="language-sh extra-class"><pre class="language-sh"><code>fatal: HttpRequestException encountered.
   发送请求时出错。
      <span class="token number">0</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token punctuation">(</span><span class="token number">32364</span><span class="token punctuation">)</span> e:<span class="token punctuation">\</span>Program Files <span class="token punctuation">(</span>x86<span class="token punctuation">)</span><span class="token punctuation">\</span>Git<span class="token punctuation">\</span>usr<span class="token punctuation">\</span>bin<span class="token punctuation">\</span>bash.exe: *** fatal error - cygheap base mismatch detected - 0x30C9408/0x2E49408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search <span class="token keyword">for</span> cygwin1.dll using the Windows Start-<span class="token operator">&gt;</span>Find/Search facility
and delete all but the <span class="token function">most</span> recent version.  The <span class="token function">most</span> recent version *should*
reside <span class="token keyword">in</span> x:<span class="token punctuation">\</span>cygwin<span class="token punctuation">\</span>bin, where <span class="token string">'x'</span> is the drive on <span class="token function">which</span> you have
installed the cygwin distribution.  Rebooting is also suggested <span class="token keyword">if</span> you
are unable to <span class="token function">find</span> another cygwin DLL.
      <span class="token number">0</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token number">31852</span> fork: child -1 - forked process <span class="token number">32364</span> died unexpectedly, retry <span class="token number">0</span>, <span class="token builtin class-name">exit</span> code 0xC0000142, errno <span class="token number">11</span>
bash: fork: retry: Resource temporarily unavailable
      <span class="token number">0</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token punctuation">(</span><span class="token number">31984</span><span class="token punctuation">)</span> e:<span class="token punctuation">\</span>Program Files <span class="token punctuation">(</span>x86<span class="token punctuation">)</span><span class="token punctuation">\</span>Git<span class="token punctuation">\</span>usr<span class="token punctuation">\</span>bin<span class="token punctuation">\</span>bash.exe: *** fatal error - cygheap base mismatch detected - 0x30C9408/0x2EB9408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search <span class="token keyword">for</span> cygwin1.dll using the Windows Start-<span class="token operator">&gt;</span>Find/Search facility
and delete all but the <span class="token function">most</span> recent version.  The <span class="token function">most</span> recent version *should*
reside <span class="token keyword">in</span> x:<span class="token punctuation">\</span>cygwin<span class="token punctuation">\</span>bin, where <span class="token string">'x'</span> is the drive on <span class="token function">which</span> you have
installed the cygwin distribution.  Rebooting is also suggested <span class="token keyword">if</span> you
are unable to <span class="token function">find</span> another cygwin DLL.
<span class="token number">1104150</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token number">31852</span> fork: child -1 - forked process <span class="token number">31984</span> died unexpectedly, retry <span class="token number">0</span>, <span class="token builtin class-name">exit</span> code 0xC0000142, errno <span class="token number">11</span>
bash: fork: retry: Resource temporarily unavailable
      <span class="token number">0</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token punctuation">(</span><span class="token number">32460</span><span class="token punctuation">)</span> e:<span class="token punctuation">\</span>Program Files <span class="token punctuation">(</span>x86<span class="token punctuation">)</span><span class="token punctuation">\</span>Git<span class="token punctuation">\</span>usr<span class="token punctuation">\</span>bin<span class="token punctuation">\</span>bash.exe: *** fatal error - cygheap base mismatch detected - 0x30C9408/0x2EE9408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search <span class="token keyword">for</span> cygwin1.dll using the Windows Start-<span class="token operator">&gt;</span>Find/Search facility
and delete all but the <span class="token function">most</span> recent version.  The <span class="token function">most</span> recent version *should*
reside <span class="token keyword">in</span> x:<span class="token punctuation">\</span>cygwin<span class="token punctuation">\</span>bin, where <span class="token string">'x'</span> is the drive on <span class="token function">which</span> you have
installed the cygwin distribution.  Rebooting is also suggested <span class="token keyword">if</span> you
are unable to <span class="token function">find</span> another cygwin DLL.
<span class="token number">3187630</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token number">31852</span> fork: child -1 - forked process <span class="token number">32460</span> died unexpectedly, retry <span class="token number">0</span>, <span class="token builtin class-name">exit</span> code 0xC0000142, errno <span class="token number">11</span>
bash: fork: retry: Resource temporarily unavailable
      <span class="token number">0</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token punctuation">(</span><span class="token number">20400</span><span class="token punctuation">)</span> e:<span class="token punctuation">\</span>Program Files <span class="token punctuation">(</span>x86<span class="token punctuation">)</span><span class="token punctuation">\</span>Git<span class="token punctuation">\</span>usr<span class="token punctuation">\</span>bin<span class="token punctuation">\</span>bash.exe: *** fatal error - cygheap base mismatch detected - 0x30C9408/0x3019408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search <span class="token keyword">for</span> cygwin1.dll using the Windows Start-<span class="token operator">&gt;</span>Find/Search facility
and delete all but the <span class="token function">most</span> recent version.  The <span class="token function">most</span> recent version *should*
reside <span class="token keyword">in</span> x:<span class="token punctuation">\</span>cygwin<span class="token punctuation">\</span>bin, where <span class="token string">'x'</span> is the drive on <span class="token function">which</span> you have
installed the cygwin distribution.  Rebooting is also suggested <span class="token keyword">if</span> you
are unable to <span class="token function">find</span> another cygwin DLL.
<span class="token number">7278726</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token number">31852</span> fork: child -1 - forked process <span class="token number">20400</span> died unexpectedly, retry <span class="token number">0</span>, <span class="token builtin class-name">exit</span> code 0xC0000142, errno <span class="token number">11</span>
bash: fork: retry: Resource temporarily unavailable
      <span class="token number">0</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token punctuation">(</span><span class="token number">9192</span><span class="token punctuation">)</span> e:<span class="token punctuation">\</span>Program Files <span class="token punctuation">(</span>x86<span class="token punctuation">)</span><span class="token punctuation">\</span>Git<span class="token punctuation">\</span>usr<span class="token punctuation">\</span>bin<span class="token punctuation">\</span>bash.exe: *** fatal error - cygheap base mismatch detected - 0x30C9408/0x2EF9408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search <span class="token keyword">for</span> cygwin1.dll using the Windows Start-<span class="token operator">&gt;</span>Find/Search facility
and delete all but the <span class="token function">most</span> recent version.  The <span class="token function">most</span> recent version *should*
reside <span class="token keyword">in</span> x:<span class="token punctuation">\</span>cygwin<span class="token punctuation">\</span>bin, where <span class="token string">'x'</span> is the drive on <span class="token function">which</span> you have
installed the cygwin distribution.  Rebooting is also suggested <span class="token keyword">if</span> you
are unable to <span class="token function">find</span> another cygwin DLL.
<span class="token number">15370228</span> <span class="token punctuation">[</span>main<span class="token punctuation">]</span> <span class="token function">bash</span> <span class="token number">31852</span> fork: child -1 - forked process <span class="token number">9192</span> died unexpectedly, retry <span class="token number">0</span>, <span class="token builtin class-name">exit</span> code 0xC0000142, errno <span class="token number">11</span>
bash: fork: Resource temporarily unavailable
error: failed to execute prompt script <span class="token punctuation">(</span>exit code <span class="token number">254</span><span class="token punctuation">)</span>
fatal: could not <span class="token builtin class-name">read</span> Username <span class="token keyword">for</span> <span class="token string">'https://github.com'</span><span class="token builtin class-name">:</span> No error
</code></pre></div><ul><li>导致：<code>fatal: HttpRequestException encountered</code> 这个的原因是github禁用了TLS1.0/1.1协议，<a href="https://githubengineering.com/crypto-deprecation-notice/" target="_blank" rel="noopener noreferrer">github禁用了对弱加密的支持<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>，我们可以对 <a href="https://github.com/git-for-windows/git/releases" target="_blank" rel="noopener noreferrer">git for windows<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> 更新到最新的版本或者去更新<a href="https://github.com/Microsoft/Git-Credential-Manager-for-Windows" target="_blank" rel="noopener noreferrer">windows的git凭证管理器<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>，这样就可以了。</li></ul> <p><img src="/assets/img/1323758-20180712112225701-1623212436.1b30de1e.png" alt="pic"></p> <h3 id="git-merge-冲突-提示you-have-not-concluded-your-merge-merge-head-exists-2"><a href="#git-merge-冲突-提示you-have-not-concluded-your-merge-merge-head-exists-2" class="header-anchor">#</a> git merge 冲突，提示You have not concluded your merge (MERGE_HEAD exists)</h3> <div class="language-sh extra-class"><pre class="language-sh"><code>You have not concluded your merge <span class="token punctuation">(</span>MERGE_HEAD exists<span class="token punctuation">)</span>.Please, commit your changes before you can merge.
</code></pre></div><ul><li>可以先撤销合并</li></ul> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token function">git</span> merge --abort <span class="token punctuation">[</span>Since <span class="token function">git</span> version <span class="token number">1.7</span>.4<span class="token punctuation">]</span>

<span class="token function">git</span> reset --merge <span class="token punctuation">[</span>prior <span class="token function">git</span> versions<span class="token punctuation">]</span>
</code></pre></div><h3 id="撤销上一次-commit-将改动保留在暂存区"><a href="#撤销上一次-commit-将改动保留在暂存区" class="header-anchor">#</a> 撤销上一次 commit，将改动保留在暂存区</h3> <ul><li>只想为之前的commit增加更多的改动，或者改变之前的提交信息</li></ul> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token comment"># 和git rest HEAD~ 有些类似，但是会将你的改动保留在暂存区内</span>
get reset --soft HEAD~
</code></pre></div><h3 id="通过-ssh-add-管理-ssh密钥-重启电脑后需要再次输入密钥密码"><a href="#通过-ssh-add-管理-ssh密钥-重启电脑后需要再次输入密钥密码" class="header-anchor">#</a> 通过 ssh-add 管理 ssh密钥，重启电脑后需要再次输入密钥密码</h3> <ul><li>ssh-add 这个命令不是用来永久性的记住你所使用的私钥的。实际上，它的作用只是把你指定的私钥添加到 ssh-agent 所管理的一个 session 当中。而 ssh-agent 是一个用于存储私钥的临时性的 session 服务，也就是说当你重启之后，ssh-agent 服务也就重置了。</li> <li>Mac 系统内置了一个 Keychain 的服务及其管理程序，可以方便的帮你管理各种秘钥，其中包括 ssh 秘钥。ssh-add 默认将制定的秘钥添加在当前运行的 ssh-agent 服务中，但是你可以改变这个默认行为让它添加到 keychain 服务中，让 Mac 来帮你记住、管理并保障这些秘钥的安全性，命令如下：</li></ul> <div class="language-sh extra-class"><pre class="language-sh"><code>ssh-add -K <span class="token punctuation">[</span>path/to/your/ssh-key<span class="token punctuation">]</span>
</code></pre></div><h3 id="windows-使用-ssh-add-管理-ssh密钥"><a href="#windows-使用-ssh-add-管理-ssh密钥" class="header-anchor">#</a> windows 使用 ssh-add 管理 ssh密钥</h3> <ul><li>windows 上可以使用 <code>scoop</code> 来安装 <code>git openssh</code></li> <li>使用 <code>ssh-add</code> 来添加密钥，如果失败，可以查看 <code>ssh-agent</code> 服务是否开启: <em><a href="https://stackoverflow.com/questions/52113738/starting-ssh-agent-on-windows-10-fails-unable-to-start-ssh-agent-service-erro" target="_blank" rel="noopener noreferrer">stackoverflow相关问题<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></em></li></ul> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token operator">&gt;</span> Get-Service ssh-agent
Status   Name               DisplayName
------   ----               -----------
Stopped  ssh-agent          OpenSSH Authentication Agent

<span class="token operator">&gt;</span> Set-Service -Name ssh-agent -StartupType Manual
<span class="token operator">&gt;</span> Start-Service ssh-agent
<span class="token operator">&gt;</span> Get-Service ssh-agent
Status   Name               DisplayName
------   ----               -----------
Running  ssh-agent          OpenSSH Authentication Agent
</code></pre></div><ul><li>可以通过 <code>ssh-add -l</code> 来确私钥列表</li> <li>可以通过 <code>ssh-add -D</code> 来清空私钥列表</li></ul> <h3 id="配置多个ssh-key"><a href="#配置多个ssh-key" class="header-anchor">#</a> 配置多个SSH-Key</h3> <p>创建多个 ssh-key 并添加到远程仓库中，</p> <ul><li><code>ssh-keygen -t rsa -C &quot;your_email@example.com&quot; -f ~/.ssh/id_rsa_github</code></li> <li><code>ssh-keygen -t rsa -C &quot;your_email@example.com&quot; -f ~/.ssh/id_rsa_gitlab</code></li></ul> <p>然后在本地 <code>.ssh</code> 文件夹下创建 <code>config</code> 文件 <code>touch config</code>，写入如下配置（<em>windows下路径为 <code>C:\Users\{用户}\.ssh</code></em>）:</p> <div class="language-sh extra-class"><pre class="language-sh"><code><span class="token comment"># gitlab</span>
Host gitlab.com
    HostName gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_gitlab
<span class="token comment"># github</span>
Host github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_github
</code></pre></div><p><em>注意：即使是同一个email地址，在不同的电脑上，都需要重新生成SSH-Key；然后再添加到git服务器的SSH-Key配置中。</em></p> <h4 id="测试"><a href="#测试" class="header-anchor">#</a> 测试</h4> <ul><li>执行如下命令，查看我们配置是否成功 <code>ssh -T git@github.com</code>，如果成功输出欢迎语句，则表示配置成功。例如：<code>Hi hdszylcd19! You've successfully authenticated, but GitHub does not provide shell access.</code></li> <li>如果遇到错误的话，则可以使用如下命令，查看详细信息，定位具体原因 <code>ssh -vT git@github.com</code> <em>一般有问题大部分都是 host 写错啦~</em></li></ul></div> <footer class="page-edit" style="display:none;"><!----> <!----></footer> <!----> <!----> <!----></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div><div class="kanbanniang" data-v-5775ee02><div class="banniang-container" style="display:;" data-v-5775ee02><div class="messageBox" style="right:68px;bottom:190px;display:none;" data-v-5775ee02>
      欢迎来到 人间熙攘，好久不见
    </div> <div class="operation" style="right:90px;bottom:40px;display:none;" data-v-5775ee02><i class="kbnfont kbn-ban-home ban-home" data-v-5775ee02></i> <i class="kbnfont kbn-ban-message message" data-v-5775ee02></i> <i class="kbnfont kbn-ban-close close" data-v-5775ee02></i> <a target="_blank" href="https://vuepress-theme-reco.recoluan.com/views/plugins/kanbanniang.html" data-v-5775ee02><i class="kbnfont kbn-ban-info info" data-v-5775ee02></i></a> <i class="kbnfont kbn-ban-theme skin" style="display:none;" data-v-5775ee02></i></div> <canvas id="banniang" width="150" height="220" class="live2d" style="right:90px;bottom:-20px;opacity:0.9;" data-v-5775ee02></canvas></div> <div class="showBanNiang" style="display:none;" data-v-5775ee02>
    看板娘
  </div></div><canvas id="vuepress-canvas-cursor"></canvas><canvas id="vuepress-canvas-ribbon"></canvas></div></div>
    <script src="/assets/js/app.fe0f04fe.js" defer></script><script src="/assets/js/3.8f0a3ee6.js" defer></script><script src="/assets/js/1.0d4da6ad.js" defer></script><script src="/assets/js/7.ccf4b6c6.js" defer></script>
  </body>
</html>
